home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl -w
-
- #############################################################
- # Copyright (C) 1998-2000 VMware, Inc.
- # All Rights Reserved
- # $Id: init.pl,v 1.46 2001/07/30 19:17:52 mgu Exp $
- #############################################################
-
- #
- # VMServerd configuration script. This script is used to setup the
- # VMserverd server.
- #
- # This script should be installed in a location that can be found
- # by vmserverd. The location by default is /home/vmware/etc.
- #
-
-
- #############################################################
- # Set up include paths
- #############################################################
- BEGIN {
- $ENV{vmware_VMSERVERD} = 1;
- $ENV{vmware_PROFILE} = 0;
-
- if ( $^O eq "MSWin32" ) {
- if (-d '%winlibdir%') {
- $PREFIX_PATH = '%winlibdir%';
- } else {
- $PREFIX_PATH = 'm:/bora-winroot/vmserverdPerl';
- }
- @INC = ("$PREFIX_PATH/5.00503/lib",
- "$PREFIX_PATH/5.00503/lib/MSWin32-x86",
- "$PREFIX_PATH/site/5.00503/lib",
- "$PREFIX_PATH/site/5.00503/lib/MSWin32-x86",
- "$PREFIX_PATH/vmware/perlroot",
- '.'
- );
- } else {
- if( -d '%libdir%' ) {
- $PREFIX_PATH = '%libdir%';
- } else {
- $PREFIX_PATH = '/usr/lib/vmware';
- }
- @INC = ("$PREFIX_PATH/perl5",
- "$PREFIX_PATH/perl5/5.00503",
- "$PREFIX_PATH/perl5/5.00503/i386-linux",
- "$PREFIX_PATH/perl5/site-perl/i386-linux",
- "$PREFIX_PATH/perl5/site_perl/5.005",
- "$PREFIX_PATH/perl5/site_perl/5.005/i386-linux",
- '.'
- );
- }
- }
-
- #############################################################
- # Common modules shared between GSX and ESX.
- #############################################################
- use strict;
- use VMware::VMServerd qw(&Log);
- use VMware::DOMAccess;
- use VMware::VMServerd::EventLog;
- use VMware::VMServerd::Who;
- use VMware::VMServerd::Info;
- use VMware::VMServerd::Mac;
- use VMware::VMServerd::Query;
- use VMware::VMServerd::Stats;
- use VMware::VMServerd::HTTP;
- use VMware::VMServerd::VMList;
-
- BEGIN {
- no strict;
- $IS_GSX = '@@IS_WGS_SERVER@@';
- $IS_ESX = '@@IS_SCALABLE_SERVER@@';
-
-
- if( $IS_ESX ) {
- # Put modules that belong to ESX here
- require VMware::VMServerd::ESXHostInfo;
- require VMware::VMServerd::ESXHostEdit;
- require VMware::VMServerd::FileSystem;
- require VMware::VMServerd::ESXResourceInfo;
- require VMware::VMServerd::ESXResourceEdit;
- require VMware::VMServerd::ESXVMConfigInfo;
- require VMware::VMServerd::ESXVMConfigEdit;
- require VMware::VMServerd::ESXVMDeleteInfo;
- require VMware::VMServerd::ESXVMDeleteEdit;
- }
-
- if( $IS_GSX ) {
- # Put modules that belong to GSX here
- require VMware::VMServerd::Disk;
- require VMware::VMServerd::VMDeleteInfo;
- require VMware::VMServerd::VMDeleteEdit;
- require VMware::VMServerd::GSXHostInfo;
- }
- }
-
- #############################################################
- # Turn on verbose error/warning reporting by uncommenting
- # the following line:
- #############################################################
- #&VMware::VMServerd::setVerbose(1);
-
- #############################################################
- # Define operations and the Perl functions to be executed
- # when a request for such an operation is received.
- # Permissions information is also indicated here.
- #############################################################
- VMware::VMServerd::addOperation( OPNAME => 'inc',
- PERLFUNC => 'main::increment' );
-
- VMware::VMServerd::addOperation( OPNAME => 'dec',
- PERLFUNC => 'main::decrement' );
-
- VMware::VMServerd::addOperation( OPNAME => 'div',
- PERLFUNC => 'main::divide' );
-
- VMware::VMServerd::addOperation( OPNAME => 'Directory_List',
- PERLFUNC => 'VMware::VMServerd::Handlers::Directory_List_Handler',
- POLICY => 'authuser' );
-
- VMware::VMServerd::addOperation( OPNAME => 'Directory_Make',
- PERLFUNC => 'VMware::VMServerd::Handlers::Directory_Make_Handler',
- POLICY => 'authuser' );
-
- VMware::VMServerd::addOperation( OPNAME => 'Directory_Remove',
- PERLFUNC => 'VMware::VMServerd::Handlers::Directory_Remove_Handler',
- POLICY => 'authuser' );
-
- VMware::VMServerd::addOperation( OPNAME => 'Directory_GetSpaceUsage',
- PERLFUNC => 'VMware::VMServerd::Handlers::Directory_GetSpaceUsage_Handler',
- POLICY => 'authuser' );
-
- VMware::VMServerd::addOperation( OPNAME => 'File_Create',
- PERLFUNC => 'VMware::VMServerd::Handlers::File_Create_Handler',
- POLICY => 'authuser' );
-
- VMware::VMServerd::addOperation( OPNAME => 'File_Read',
- PERLFUNC => 'VMware::VMServerd::Handlers::File_Read_Handler',
- POLICY => 'authuser' );
-
- VMware::VMServerd::addOperation( OPNAME => 'File_Exists',
- PERLFUNC => 'VMware::VMServerd::Handlers::File_Exists_Handler',
- POLICY => 'authuser' );
-
- VMware::VMServerd::addOperation( OPNAME => 'File_Copy',
- PERLFUNC => 'VMware::VMServerd::Handlers::File_Copy_Handler',
- POLICY => 'authuser' );
-
- VMware::VMServerd::addOperation( OPNAME => 'File_Delete',
- PERLFUNC => 'VMware::VMServerd::Handlers::File_Delete_Handler',
- POLICY => 'authuser' );
-
- VMware::VMServerd::addOperation( OPNAME => 'Host_GetVirtualNet',
- PERLFUNC => 'VMware::VMServerd::Handlers::Host_GetVirtualNet_Handler',
- POLICY => 'authuser' );
-
- VMware::VMServerd::addOperation( OPNAME => 'Host_GetBridgedNet',
- PERLFUNC => 'VMware::VMServerd::Handlers::Host_GetBridgedNet_Handler',
- POLICY => 'authuser' );
-
- VMware::VMServerd::addOperation( OPNAME => 'Host_GetHostOnlyNet',
- PERLFUNC => 'VMware::VMServerd::Handlers::Host_GetHostOnlyNet_Handler',
- POLICY => 'authuser' );
-
- Log("\nFiles included by init.pl:\n");
- my $f;
- foreach $f (keys(%INC)) {
- my $abspath = $INC{$f};
- Log(" module $f -> $abspath\n");
- }
- Log("\n\n" .
- "Operations defined in function table:\n" .
- &VMware::VMServerd::dumpOperation() .
- "\n"
- );
-
- #############################################################
- # Some sample Perl request handling functions. These are
- # sample functions and should really go in a separate file
- #############################################################
- sub increment($$) {
- my $in = shift;
- my $out = shift;
-
- my $s;
- $s = $in->getValue(".number");
- $s++;
-
- $out->setValue(".number", $s);
-
- return(1);
- }
-
- sub decrement($$) {
- my $in = shift;
- my $out = shift;
-
- my $s;
- $s = $in->getValue(".number");
- $s--;
-
- $out->setValue(".number", $s);
-
- return(1);
- }
-
- sub divide($$) {
- my $in = shift;
- my $out = shift;
-
- my($s, $t);
- $s = $in->getValue(".number1");
- $t = $in->getValue(".number2");
-
- if( $t == 0 ) {
- die "Divide by zero";
- }
-
- $out->setValue(".number", sprintf("%d", $s/$t));
-
- return(1);
- }
-
- #############################################################
- # Some Perl request handling functions that are common to both
- # SS and WGS. These should be moved elsewhere in the future.
- #############################################################
- package VMware::VMServerd::Handlers;
-
- my %gHelpers = (
- ls => "ls",
- mkdir => "mkdir",
- ifconfig => "ifconfig",
- df => "df"
- );
-
- my $DEFAULT_DIR_MODE = 0755;
- my $DEFAULT_FILE_MODE = 0644;
-
- sub isAbsolutePath($) {
- my ($file) = @_;
-
- if (($^O =~ /MSWin32/i) &&
- (($file =~ /^[a-zA-Z]:/) || ($file =~ /^\\/))) {
- return 1;
- }
- if (($^O =~ /linux/i) &&
- (substr($file, 0, 1) eq '/')) {
- return 1;
- }
-
- return 0;
- }
-
- #
- # Gets a list of files from a directory.
- #
- # Input format:
- # directory := the absolute path name of the directory
- #
- # Output includes information about each file.
- # Output format:
- #
- # file.name := the path name of the file relative to the directory
- # file.type := regular | directory | symlink | FIFO | socket |
- # block | char | tty | unknown
- # file.mode := an integer corresponding to the mode of the file
- # file.uid := integer corresponding to owner of file
- # file.gid := integer corresponding to group of file
- # file.size := size of file in bytes
- # file.atime := last access time since the epoch in milliseconds
- # file.mtime := last modified time since the epoch in milliseconds
- #
- # Note that symlinks are simply recognized as the files to which
- # they point. If the symlink is broken, it is ignored.
- #
- sub Directory_List_Handler($$) {
- my $in = shift;
- my $out = shift;
- my $dir = $in->getValue(".directory");
-
- &VMware::VMServerd::errorReset();
- # Validation on the input parameters
- if( !defined($dir) || $dir eq "" ) {
- &VMware::VMServerd::errorPost("No directory specified");
- return 0;
- }
-
- if (! isAbsolutePath($dir)) {
- &VMware::VMServerd::errorPost("Not an absolute path $dir");
- return 0;
- }
-
- if( ! -d $dir ) {
- &VMware::VMServerd::errorPost("$dir is not a directory");
- return 0;
- }
-
- # Get the list of files
- local *DIR;
- if( !opendir(DIR, $dir) ) {
- &VMware::VMServerd::errorPost("Cannot open the directory. Reason: $!");
- return 0;
- }
-
- my @files = readdir(DIR);
- closedir DIR;
-
- my $i;
- for( $i = 0; $i <= $#files; $i++ ) {
- my $abspath = &VMware::ExtHelpers::absolute_path($files[$i], $dir);
-
- my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
- $atime, $mtime, $ctime, $blksize, $blocks);
-
- # Skip if we can't get file info.
- if( !(($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
- $atime, $mtime, $ctime, $blksize, $blocks) = stat($abspath)) ) {
- next;
- }
-
- my $filetype;
- if( -f $abspath ) {
- $filetype = "regular";
- } elsif( -d $abspath ) {
- $filetype = "directory";
- } elsif( -p $abspath ) {
- $filetype = "FIFO";
- } elsif( -S $abspath ) {
- $filetype = "socket";
- } elsif( -b $abspath ) {
- $filetype = "block";
- } elsif( -c $abspath ) {
- $filetype = "char";
- } elsif( -t $abspath ) {
- $filetype = "tty";
- } else {
- $filetype = "";
- }
-
- $out->setValue(".file[$i].name", $files[$i]);
- $out->setValue(".file[$i].type", $filetype);
- $out->setValue(".file[$i].mode", $mode);
- $out->setValue(".file[$i].uid", $uid);
- $out->setValue(".file[$i].gid", $gid);
- $out->setValue(".file[$i].size", $size);
- $out->setValue(".file[$i].atime", $atime);
- $out->setValue(".file[$i].mtime", $mtime);
- }
-
- if (&VMware::VMServerd::haveError()) {
- &VMware::VMServerd::errorPost("");
- }
-
- return(1);
- }
-
-
- #
- # Makes a new directory
- #
- # Input format:
- # directory := the absolute path name of the directory
- # mode := the file mode to use. Uses $DEFAULT_DIR_MODE as default.
- #
- # Output includes information about each file.
- # Output format:
- #
- # No output on success.
- #
- sub Directory_Make_Handler($$) {
- my $in = shift;
- my $out = shift;
- my $dir = $in->getValue(".directory");
- my $mode;
-
- &VMware::VMServerd::errorReset();
-
- if ($in->hasElement(".mode") ) {
- $mode = $in->getValue(".mode");
- if( $mode =~ /^[0-7]+$/ ) {
- $mode = oct($mode);
- } elsif( $mode ne "" ) {
- &VMware::VMServerd::errorPost("Invalid mode specified");
- return 0;
- }
- }
-
- # Validation on the input parameters
- if( !defined($dir) || $dir eq "" ) {
- &VMware::VMServerd::errorPost("No directory specified");
- return 0;
- }
-
- if (! isAbsolutePath($dir)) {
- &VMware::VMServerd::errorPost("Not an absolute path $dir");
- return 0;
- }
-
- if( !defined($mode) || ($mode eq "") ) {
- $mode = $DEFAULT_DIR_MODE;
- }
-
- $dir = &VMware::ExtHelpers::dir_remove_trailing_slashes($dir);
-
- $dir =~ s/^([a-zA-Z]:)//;
- my $driveLetters = defined($1) ? $1 : '';
- my @dirs = ($^O eq "MSWin32") ? split(/\\/, $dir) : split(/\//, $dir);
- my $cdir = $driveLetters;
- my $d;
- foreach $d (@dirs) {
- if( $d eq "" ) {
- next;
- }
- $cdir .= (($^O eq "MSWin32") ? '\\' : '/') . $d;
- if( -d $cdir && $cdir ne $dir ) {
- next;
- } else {
- if( !mkdir($cdir, $mode) ) {
- &VMware::VMServerd::errorPost("mkdir failed. Reason: $! ");
- return 0;
- }
- }
- }
-
- return(1);
- }
-
-
- #
- # Remove a directory
- #
- # Input format:
- # directory := the absolute path name of the directory
- #
- # Output includes information about each file.
- # Output format:
- #
- # No output on success.
- #
- sub Directory_Remove_Handler($$) {
- my $in = shift;
- my $out = shift;
- my $dir = $in->getValue(".directory");
-
- &VMware::VMServerd::errorReset();
- # Validation on the input parameters
- if( !defined($dir) || $dir eq "" ) {
- &VMware::VMServerd::errorPost("No directory specified");
- return 0;
- }
-
- if (! isAbsolutePath($dir)) {
- &VMware::VMServerd::errorPost("Not an absolute path $dir");
- return 0;
- }
-
- if( !rmdir($dir) ) {
- &VMware::VMServerd::errorPost("rmdir failed. Reason: $! ");
- return 0;
- }
-
- return(1);
- }
-
-
- #
- # Gets the space information about a directory including the
- # amount of space used, free, and total.
- #
- # Input format:
- # directory := the absolute path name of the directory to
- # check for free space
- #
- # Output includes information about each file.
- # Output format:
- #
- # used := number of kbytes that are used
- # free := number of kbytes that are free
- # total := total number of kbytes
- #
- sub Directory_GetSpaceUsage_Handler($$) {
- my $in = shift;
- my $out = shift;
- my $dir = $in->getValue(".directory");
-
- &VMware::VMServerd::errorReset();
- # Validation on the input parameters
- if( !defined($dir) || $dir eq "" ) {
- &VMware::VMServerd::errorPost("No directory specified");
- return 0;
- }
-
- if (! isAbsolutePath($dir)) {
- &VMware::VMServerd::errorPost("Not an absolute path $dir");
- return 0;
- }
-
- if( ! -d $dir ) {
- &VMware::VMServerd::errorPost("$dir is not a directory");
- return 0;
- }
-
- local *FD;
- # Use -k to get kbytes
- if( !open(FD, shell_string($gHelpers{df}) . " -k " . shell_string($dir) . " |") ) {
- &VMware::VMServerd::errorPost("Could not execute " . $gHelpers{df});
- return 0;
- }
-
- my $total;
- my $used;
- my $free;
-
- while(<FD>) {
- if( /\/dev\/\S+\s+(\d+)\s+(\d+)\s+(\d+)/ ) {
- $total = $1;
- $used = $2;
- $free = $3;
- }
- }
- close(FD);
-
- if( !defined($total) || !defined($used) || !defined($free) ) {
- &VMware::VMServerd::errorPost("Could not read directory space usage information");
- return 0;
- }
-
- $out->setValue(".total", $total);
- $out->setAttribute(".total", "units", "kbyte");
- $out->setValue(".used", $used);
- $out->setAttribute(".used", "units", "kbyte");
- $out->setValue(".free", $free);
- $out->setAttribute(".free", "units", "kbyte");
-
- return(1);
- }
-
- #
- # Create a file with the given contents
- #
- # Input format:
- # file := the absolute path name of the file to be created
- # data := the data to put into the new file
- # mode := the mode of the file (optional)
- # o_create := flag to ignore the check for existence of the file.
- # passing 1 to this parameter will cause
- #
- # Output includes information about each file.
- # Output format:
- #
- # No output on success.
- #
- sub File_Create_Handler($$) {
- my $in = shift;
- my $out = shift;
- my $file = $in->getValue(".file");
- my $data = $in->getValue(".data");
- my $o_create = $in->getValue(".o_create");
- my $mode;
- my $modeStr;
-
- &VMware::VMServerd::errorReset();
-
- if ($in->hasElement(".mode")) {
- $mode = $in->getValue(".mode");
- $modeStr = $mode;
- if( $mode =~ /^[0-7]+$/ ) {
- $mode = oct($mode);
- } elsif( $mode ne "" ) {
- &VMware::VMServerd::errorPost("Invalid mode specified");
- return 0;
- }
- }
-
- # Validation on the input parameters
- if( !defined($file) || $file eq "" ) {
- &VMware::VMServerd::errorPost("No file specified");
- return 0;
- }
-
- if (! isAbsolutePath($file)) {
- &VMware::VMServerd::errorPost("Not an absolute path $file");
- return 0;
- }
-
- if( !defined($mode) || ($mode eq "") ) {
- $mode = $DEFAULT_FILE_MODE;
- }
-
- if( $o_create ne "1" && -e $file ) {
- &VMware::VMServerd::errorPost("File exists");
- return 0;
- }
-
- local *FD;
- if( !open(FD, "> $file") ) {
- &VMware::VMServerd::errorPost("File open failed. Reason: $!");
- return 0;
- }
-
- print FD $data;
- close(FD);
-
- if( !chmod($mode, $file) ) {
- &VMware::VMServerd::errorPost("File created but could not change mode to " . $modeStr);
- return 0;
- }
-
- return(1);
- }
-
-
- #
- # Get the contents of a file.
- #
- # Input format:
- # file := the absolute path name of the file to be read.
- #
- # Output includes information about each file.
- # Output format:
- #
- # data := the data in the file
- #
- sub File_Read_Handler($$) {
- my $in = shift;
- my $out = shift;
- my $file = $in->getValue(".file");
- my $data = "";
-
- &VMware::VMServerd::errorReset();
- # Validation on the input parameters
- if( !defined($file) || $file eq "" ) {
- &VMware::VMServerd::errorPost("No file specified");
- return 0;
- }
-
- if (! isAbsolutePath($file)) {
- &VMware::VMServerd::errorPost("Not an absolute path $file");
- return 0;
- }
-
- local *FD;
- if( !open(FD, "< $file") ) {
- &VMware::VMServerd::errorPost("Open failed. Reason: $!");
- return 0;
- }
-
- while(<FD>) {
- $data .= $_;
- }
- close(FD);
-
- $out->setValue(".data", $data);
-
- return(1);
- }
-
-
- #
- # Checks if a file/directory exists. Gets the permissions on the file.
- #
- # Input format:
- # file := the absolute path name of the file to be read.
- #
- # Output includes information about each file.
- # Output format:
- # exists := 0 | 1
- # directory := 0 | 1
- # read := 0 | 1
- # write := 0 | 1
- # execute := 0 | 1
- #
- sub File_Exists_Handler($$) {
- my $in = shift;
- my $out = shift;
- my $file = $in->getValue(".file");
-
- &VMware::VMServerd::errorReset();
- $out->setValue(".exists", 0);
- $out->setValue(".directory", 0);
- $out->setValue(".read", 0);
- $out->setValue(".write", 0);
- $out->setValue(".execute", 0);
-
- # Validation on the input parameters
- if( !defined($file) || $file eq "" ) {
- &VMware::VMServerd::errorPost("No file specified");
- return 0;
- }
-
- if (! isAbsolutePath($file)) {
- &VMware::VMServerd::errorPost("Not an absolute path $file");
- return 0;
- }
-
- my $exists = (-e $file ? 1 : 0);
- my $directory = (-d $file ? 1 : 0);
- my $read = (-r $file ? 1 : 0);
- my $write = (-w $file ? 1 : 0);
- my $execute = (-x $file ? 1 : 0);
-
- $out->setValue(".exists", $exists);
- $out->setValue(".directory", $directory);
- $out->setValue(".read", $read);
- $out->setValue(".write", $write);
- $out->setValue(".execute", $execute);
-
- return(1);
- }
-
-
- #
- # Copy a file.
- #
- # Input format:
- # src := the absolute path name of the file to be read.
- # dest := the absoluate path name of the file to be written.
- #
- # Output includes information about each file.
- # Output format:
- #
- # No output on success.
- #
- sub File_Copy_Handler($$) {
- my $in = shift;
- my $out = shift;
- my $src = $in->getValue(".src");
- my $dest = $in->getValue(".dest");
- my $data = "";
-
- &VMware::VMServerd::errorReset();
- # Validation on the input parameters
- if( !defined($src) || $src eq "" ) {
- &VMware::VMServerd::errorPost("No input file specified");
- return 0;
- }
-
- # Validation on the input parameters
- if( !defined($dest) || $dest eq "" ) {
- &VMware::VMServerd::errorPost("No output file specified");
- return 0;
- }
-
- if (! isAbsolutePath($src)) {
- &VMware::VMServerd::errorPost("Not an absolute path: $src");
- return 0;
- }
-
- if (! isAbsolutePath($dest)) {
- &VMware::VMServerd::errorPost("Not an absolute path: $dest");
- return 0;
- }
-
- local(*RFD, *WFD);
- if( !open(RFD, "< $src") ) {
- &VMware::VMServerd::errorPost("Open for $src failed. Reason: $!");
- return 0;
- }
-
- if( !open(WFD, "> $dest") ) {
- &VMware::VMServerd::errorPost("Open for $dest failed. Reason: $!");
- close(RFD);
- return 0;
- }
-
- # Some crazy OSs distinguish between text and binary files.
- binmode(RFD);
- binmode(WFD);
-
- while(<RFD>) {
- print WFD;
- }
-
- close(RFD);
- close(WFD);
-
- return(1);
- }
-
-
- #
- # Deletes a file.
- #
- # Input format:
- # file := the absolute path name of the file to be deleted
- #
- # Output includes information about each file.
- # Output format:
- #
- # No output on success.
- #
- sub File_Delete_Handler($$) {
- my $in = shift;
- my $out = shift;
- my $file = $in->getValue(".file");
- my $data = "";
-
- &VMware::VMServerd::errorReset();
-
- # Validation on the input parameters
- if( !defined($file) || $file eq "" ) {
- &VMware::VMServerd::errorPost("No file specified");
- return 0;
- }
-
- if (! isAbsolutePath($file)) {
- &VMware::VMServerd::errorPost("Not an absolute path: $file");
- return 0;
- }
-
- # Make sure this is a regular file. Otherwise, we could get
- # some bad side effects.
- if( ! -f $file ) {
- &VMware::VMServerd::errorPost("File '$file' is not a regular file");
- return 0;
- }
-
- if (!unlink($file)) {
- &VMware::VMServerd::errorPost("Could not remove file $file. Reason: $!");
- return 0;
- }
-
- return(1);
- }
-
- #
- # Gets the virtual network interfaces on the system.
- #
- # Input format:
- # No input args.
- #
- # Output includes information about each file.
- # Output format:
- #
- # .net.interface := the name of the virtual interface
- # .net.type := bridged | hostonly
- # <others> depends on Host_GetBridgedNet_Handler and
- # Host_GetHostOnlyNet_Handler
- #
- sub Host_GetVirtualNet_Handler($$) {
- my $in = shift;
- my $out = shift;
- Host_GetBridgedNet_Handler($in, $out);
- Host_GetHostOnlyNet_Handler($in, $out);
- return(1);
- }
-
-
- #
- # Gets the bridged network interfaces on the system.
- #
- # Input format:
- # No input args.
- #
- # Output includes information about each file.
- # Output format:
- #
- # .net.interface := the name of the virtual interface
- # .net.type := bridged
- # .net.ethdev := the real ethernet device to which the virtual
- # interface is bound
- #
- sub Host_GetBridgedNet_Handler($$) {
- my $in = shift;
- my $out = shift;
-
- my @nets = $out->listElementNames("out", "^net");
- my $i = $#nets + 1;
- $out->setValue(".net[$i].interface", "vmnet0");
- $out->setValue(".net[$i].type", "bridged");
- $out->setValue(".net[$i].ethdev", "eth0");
- return(1);
- }
-
-
- #
- # Gets the hostonly network interfaces on the system.
- #
- # Input format:
- # No input args.
- #
- # Output includes information about each file.
- # Output format:
- #
- # .net.interface := the name of the virtual interface
- # .net.type := hostonly
- # .net.hostaddr := the host address for the host machine
- # .net.netmask := the netmask for the virtual network
- #
- sub Host_GetHostOnlyNet_Handler($$) {
- my $in = shift;
- my $out = shift;
-
- my @nets = $out->listElementNames("out", "^net");
- my $i = $#nets + 1;
- $out->setValue(".net[$i].interface", "vmnet1");
- $out->setValue(".net[$i].type", "hostonly");
- # $out->setValue(".net[$i].hostaddr", "192.168.0.1");
- # $out->setValue(".net[$i].netmask", "255.255.255.0");
- return(1);
- }
-
- # Convert a string to its equivalent shell representation
- sub shell_string {
- my $single_quoted = shift;
-
- $single_quoted =~ s/'/'"'"'/g;
- # This comment is a fix for emacs's broken syntax-highlighting code --hpreg
- return '\'' . $single_quoted . '\'';
- }
-
- 1;
-
-